Appendix D : Emulator Detection - Where am I?

Writers of software on the C64 or emulators may wish to know whether the "machine" their code is executing on is a real C64, or not (e.g. for disabling fastloaders). Wolfgang Lorenz, the author or PC64, suggested a method that reveals the type of emulator based on a special use of the addresses $DF80-$DFFF. See the following listing for details.

If you want to test this program on Power64, just copy the text from this document and paste it into an open Power64 emulator window. Power64 will respond with the following message:

          Power64 (2.1.2)
 Commodore 64 for Power Macintosh
      (C) 1998 Roland Lieger

If the emulator detection awareness of Power64 should cause trouble with a program it can be disabled using the Options/ROM Patches dialog.

100 REM ********* WHERE AM I? *********
110 REM -------------------------------
120 REM THIS IS THE RECOMMENDED METHOD
130 REM HOW TO DETECT A C64 EMULATOR,
140 REM E.G. FOR DISABLING FAST LOADERS
150 REM
160 REM - THE BYTE AT $DFFF CHANGES
170 REM   BETWEEN $55 AND $AA ON EVERY
180 REM   READ ACCESS
190 REM - THE BYTE AT $DFFE CONTAINS
200 REM   THE MANUFACTURER CODE LETTER:
210 REM   A = C64ALIVE
220 REM   F = FRODO
230 REM   P = PERSONAL C64
240 REM   S = C64 SOFTWARE EMULATOR
250 REM   X = X64
260 REM   / = POWER64
270 REM - THE WORD AT $DFFC CONTAINS
280 REM   THE EMULATOR VERSION NUMBER,
290 REM   E.G. $0120 FOR VERSION 1.2
300 REM - THE BYTES FROM $DFA0 CONTAIN
310 REM   A COPYRIGHT STRING WITH
320 REM   EMULATOR NAME AND VERSION,
330 REM   $0D, COPYRIGHT AND $00.
340 REM -------------------------------
350 :
500 PRINT
510 X=57343: REM $DFFF
520 IF PEEK(X)<>85 THEN IF PEEK(X)<>85 THEN 1000
530 IF PEEK(X)<>170 THEN 1000
540 IF PEEK(X)<>85  THEN 1000
550 IF PEEK(X)<>170 THEN 1000
560 M$=CHR$(PEEK(57342)): REM $DFFE
570 PRINT "MANUFACTURER = '"; M$; "' ";
580 IF M$="A" THEN PRINT "(C64ALIVE)";
590 IF M$="F" THEN PRINT "(FRODO)";
600 IF M$="P" THEN PRINT "(PC64)";
610 IF M$="S" THEN PRINT "(C64S)";
620 IF M$="X" THEN PRINT "(X64)";
630 IF M$="/" THEN PRINT "(POWER64)";
640 PRINT
650 :
700 V=PEEK(57341)*256 + PEEK(57340): REM $DFFD/$DFFC
710 H$="0123456789ABCDEF"
720 FOR I=0 TO 3
730 V$=MID$(H$,1+(V AND 15),1)+V$
740 V=INT(V/16)
750 NEXT
760 PRINT "VERSION = $";V$
770 PRINT
780 :
800 I=57248: REM $DFA0
810 X=PEEK(I)
820 IF X=0 THEN PRINT: END
830 PRINT CHR$(X);
840 I=I+1
850 GOTO 810
860 :
900 REM -------------------------------
910 REM THESE ARE MANUFACTURER-SPECIFIC
920 REM WORKAROUNDS, WHICH SHOULD BE
930 REM REPLACED WITH THE OFFICIAL
940 REM EMULATOR DETECTION METHOD
950 :
1000 IF PEEK(60682)<>0 THEN 1100: REM $ED0A
1010 PRINT "C64 SOFTWARE EMULATOR"
1020 PRINT "(C)1991-94 MIHA PETERNEL"
1030 END
1040 :
1100 IF PEEK(60736)<>0 THEN 1200: REM $ED40
1110 PRINT "X64 (VERSION 1 OR 2)"
1120 PRINT "(C)1993-94 J.SONNINEN/T.RANTANEN/J.VALTA"
1130 END
1140 :
1200 X=57087: REM $DEFF
1210 IF PEEK(X)+PEEK(X)+PEEK(X)<>0 THEN 2000
1220 PRINT "C64ALIVE"
1230 PRINT "(C)1993-94 F.LITTMANN DEVELOPMENTS"
1240 END
1250 :
2000 PRINT "THIS IS AN ORIGINAL C64 OR C128"